package com.za.upgradeshield;

import com.fasterxml.jackson.databind.ObjectMapper;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

public class ResultUtil {
    private static final ObjectMapper objectMapper = new ObjectMapper();

    /**
     * 将resp对象响应到响应体中
     */
    public static void responseJson(HttpServletResponse response, Object resp) throws IOException {
        response.setContentType("application/json;charset=UTF-8");
        response.setStatus(HttpServletResponse.SC_OK);
        objectMapper.writeValue(response.getWriter(), resp);
    }
}